<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
</head>
<body>
<div id="app">
    <div>
        <span>名：</span>
        <span>
            <input type="text" v-model="firstName">
        </span>
    </div>
    <div>
        <span>姓：</span>
        <span>
            <input type="text" v-model="lastName">
        </span>
    </div>
    <div>
        {{fullName}}
        {{fullName1}}
    </div>
</div>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            firstName:'Jim',
            lastName:'Green',
            fullName:'Jim Green'
        },
        watch:{
            firstName(val){
                this.fullName = val + ' ' + this.lastName
            },
            lastName(val) {
                this.fullName = this.firstName + ' ' + val
            }
        },
        computed:{
            fullName1(){
                return this.firstName+' '+this.lastName
            }
        }
    })
</script>
</body>
</html>
